package com.berry.MedCheck;

import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.ActivityInfo;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.widget.Button;
import android.widget.ImageView;
import com.berry.MedCheck.db.DBOperatorTest;
import com.berry.MedCheck.db.MeasureDBTest;

/**
 * Created with IntelliJ IDEA.
 * User: Airay.Rong
 * Date: 13-12-3
 * Time: 下午4:44
 * To change this template use File | Settings | File Templates.
 */
public class WelcomeActivity extends Activity {
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
		setContentView(R.layout.welcome_activity);

		Button mbtnStart = (Button) findViewById(R.id.btn_start);
		mbtnStart.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				startActivity(new Intent().setClass(WelcomeActivity.this,ChooseUserActivity.class));
				finish();
			}
		});


	}

	@Override
	protected void onResume() {
		super.onResume();
		if (readPreference_Guild() == false) {
			startActivity(new Intent().setClass(WelcomeActivity.this,GuildActivity.class));
			finish();
		}
	}

	private boolean readPreference_Guild(){
		SharedPreferences sp = getSharedPreferences(Utils.PREFERENCE_NAME, 0);
		boolean bGuild = sp.getBoolean(Utils.PRE_KEY_CURRENT_GUILD,false);
		return bGuild;
	}
}